﻿﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace demo3
{
    public class Student
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public bool Wen { get; set; }
        public int Chinese { get; set; }
        public int Math { get; set; }
        public int English { get; set; }
        public int Comprehensive { get; set; }
    }
    class Program
    {
        static void Main(string[] args)
        {
            List<Student> students = new List<Student> { };
            //new Student {Id=1,Name="小红",Wen=false,Chinese=120,Math=121,English=122,Comprehensive=363},
            //new Student { Id=2,Name="小明", Wen = true, Chinese = 100, Math = 101, English = 102, Comprehensive = 303},
            //new Student { Id = 3, Name = "小李", Wen = true, Chinese = 90, Math = 91, English = 92, Comprehensive = 273 },
            // new Student { Id = 4, Name = "小王", Wen = true, Chinese = 110, Math = 111, English = 112, Comprehensive = 333 }
            //);
            students.Add(new Student() {
                Id = 1,
                Name = "小红",
                Wen = false,
                Chinese = 120,
                Math = 121,
                English = 122,
                Comprehensive = 363
            });
            students.Add(new Student()
            {
                Id = 2,
                Name = "小明",
                Wen = true,
                Chinese = 100,
                Math = 101,
                English = 102,
                Comprehensive = 303
            });
            students.Add(new Student()
            {
                Id = 3,
                Name = "小李",
                Wen = true,
                Chinese = 90,
                Math = 91,
                English = 92,
                Comprehensive = 273
            });
            students.Add(new Student()
            {
                Id = 4,
                Name = "小王",
                Wen = true,
                Chinese = 110,
                Math = 111,
                English = 112,
                Comprehensive = 333
            });
            Console.WriteLine("---------------获取文科生----------------");
            var date = students.Where(p => p.Wen == true);
         
            foreach (var item in date)
            {
                Console.WriteLine("编号：" + item.Id + ",姓名：" + item.Name + ",是否文科生：" + item.Wen + ",语文：" + item.Chinese +
                    ",数学：" + item.Math + ",英语：" + item.English + ",综合：" + item.Comprehensive);
             
            }

            Console.WriteLine("---------------获取文科生平均成绩----------------");
            var date1 = students.Where(p => p.Wen == true).Average(p => p.Chinese + p.Math + p.English + p.Comprehensive);
            Console.WriteLine(date1);
                
                
        }
    }
}
